import random
import time

import requests

# https://v16m.tiktokcdn.com/77961b7e87a5706741846e6e02102c7f/5f561533/video/tos/useast2a/tos-useast2a-ve-0068c003/42fe8cd7999c4737a466e4dcfc1e25a2/?a=1233&br=3700&bt=1850&cr=0&cs=0&cv=1&dr=0&ds=3&er=&l=202009070510270101150790880B03F229&lr=tiktok_m&mime_type=video_mp4&qs=0&rc=M3QzaHJzNXI3djMzaTczM0ApZzs2PDw2aTxpN2U4PDk4ZGdpcHIuMzIvMnNfLS0zMTZzcy82Yy8tNDUwYC0yYy9jNmM6Yw%3D%3D&vl=&vr=
def play_you():
    r = requests.get('http://134.209.103.120/InstagramFollowers/api/follower/7228542454')
    json = r.json()
    print(json)
    followers = json['followers']
    for i in followers:
        time.sleep(random.randint(2, 5))
        print(i['user_id'], i['username'])
        url = 'http://134.209.103.120/InstagramFollowers/api/userFollower'
        headers = {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Host': '134.209.103.120',
            'User-Agent': 'okhttp/3.12.1'
        }
        payload = {'user_id': '7228542454', 'request_user': i['user_id']}
        api = requests.post(url, headers=headers, data=payload)
        print(api.text, '\n')


def play_media():
    r = requests.get('http://134.209.103.120/InstagramFollowers/api/like/7228542454')
    json = r.json()
    print(json)
    followers = json['like_image']
    for i in followers:
        time.sleep(random.randint(2, 5))
        print(i['media_id'], i['media_url'])
        url = 'http://134.209.103.120/InstagramFollowers/api/userLike'
        headers = {
            'Content-Type': 'application/x-www-form-urlencoded',
            'Host': '134.209.103.120',
            'User-Agent': 'okhttp/3.12.1'
        }
        payload = {'user_id': '7228542454', "media_id": i['media_id'], 'request_user': i['user_id']}
        api = requests.post(url, headers=headers, data=payload)
        print(api.text, '\n')


if __name__ == '__main__':
    while True:
        play_media()
        time.sleep(random.randint(5, 10))
